import $ecCountDown from './utils/countDown'
//import $ecCountUp from './countup/index'

/**
 * 使用选择器选择组件实例节点，返回匹配到的第一个组件实例对象
 * @param {String} selector 节点选择器
 * @param {Object} ctx 页面栈或组件的实例，默认为当前页面栈实例
 */
const getCtx = (selector, ctx = getCurrentPages()[getCurrentPages().length - 1]) => {
  const componentCtx = ctx.selectComponent(selector)

  if (!componentCtx) {
    throw new Error('无法找到对应的组件，请按文档说明使用组件')
  }

  return componentCtx
}

//const $ecActionSheet = (selector = '#ec-actionsheet', ctx) => getCtx(selector, ctx)
const $ecBackdrop = (selector = '#ec-backdrop', ctx) => getCtx(selector, ctx)
//const $ecToast = (selector = '#ec-toast', ctx) => getCtx(selector, ctx)
//const $ecLoading = (selector = '#ec-loading', ctx) => getCtx(selector, ctx)
const $ecDialog = (selector = '#ec-dialog', ctx) => getCtx(selector, ctx)
//const $ecToptips = (selector = '#ec-toptips', ctx) => getCtx(selector, ctx)
//const $ecGallery = (selector = '#ec-gallery', ctx) => getCtx(selector, ctx)
//const $ecNotification = (selector = '#ec-notification', ctx) => getCtx(selector, ctx)
//const $ecKeyBoard = (selector = '#ec-keyboard', ctx) => getCtx(selector, ctx)
//const $stopecRefresher = (selector = '#ec-refresher', ctx) => getCtx(selector, ctx).finishPullToRefresh()

export {
  //$ecActionSheet,
  $ecBackdrop,
  //$ecToast,
  //$ecLoading,
  $ecDialog,
  //$ecToptips,
  //$ecGallery,
  //$ecNotification,
  //$ecKeyBoard,utils
  //utilutilsuuts
  //$stopecRefresher,
  $ecCountDown,
  //$ecCountUp,
}